package com.kunpeng.weibo.weixin.api;

import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.SendMessageToWX;
import com.tencent.mm.sdk.openapi.WXMediaMessage;
import com.tencent.mm.sdk.openapi.WXWebpageObject;

public class SendWebpage_API extends Request_API {

	public SendWebpage_API(IWXAPI api) {
		super(api);
	}

	public void sendWebpage(String url, String title, String desc) throws IllegalArgumentException {
		if (url == null || url.equals("") || !url.startsWith("http")) {
			throw new IllegalArgumentException();
		}
		WXWebpageObject webpage = new WXWebpageObject();
		webpage.webpageUrl = url;
		WXMediaMessage msg = new WXMediaMessage(webpage);
		if (title != null) {
			msg.title = title;
		}
		if (desc != null) {
			msg.description = desc;
		}
		SendMessageToWX.Req req = new SendMessageToWX.Req();
		req.transaction = buildTransaction("webpage");
		req.message = msg;
		mWeixinApi.sendReq(req);
	}
}
